﻿<navigation:Page x:Class="Songhay.Silverlight.BiggestBox.IndexPart.Views.UserControlsPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:m="clr-namespace:Songhay.Silverlight.BiggestBox.IndexPart.ViewModels"
    x:Name="NavigationPage"
    Title="User Control Samples">
    <navigation:Page.Resources>
        <m:UserControlsViewModel x:Key="UserControlsViewModelDataSource" d:IsDataSource="True" />

        <DataTemplate x:Key="ItemsTemplate">
            <Button Grid.Column="0"
                Command="{Binding LoadUserControlCommand, Mode=OneWay, Source={StaticResource UserControlsViewModelDataSource}}"
                CommandParameter="{Binding Name}"
                Cursor="Hand"
                Margin="8"
                VerticalAlignment="Top"
                Width="192">
                <Button.Content>
                    <toolkit:DockPanel LastChildFill="True" Margin="4">
                        <Image
                            toolkit:DockPanel.Dock="Left"
                            Source="/Songhay.Silverlight.BiggestBox.IndexPart;Component/Bitmaps/ApplicationUp.png"
                            VerticalAlignment="Top"
                            Width="32" Height="32"
                                />
                        <TextBlock
                            toolkit:DockPanel.Dock="Right"
                            ScrollViewer.VerticalScrollBarVisibility="Auto"
                            FontSize="11"
                            Height="96"
                            Margin="16,0,0,0"
                            Text="{Binding DisplayName, Mode=OneWay}"
                            TextWrapping="Wrap"
                                />
                    </toolkit:DockPanel>
                </Button.Content>
            </Button>
        </DataTemplate>
    </navigation:Page.Resources>
    <ScrollViewer
        ScrollViewer.VerticalScrollBarVisibility="Auto"
        BorderThickness="0">
        <StackPanel>
            <TextBlock
                FontSize="14"
                FontWeight="Bold"
                Foreground="DarkGray"
                Margin="14,14,0,0"
                Text="{Binding
                    ElementName=NavigationPage,
                    Path=Title,
                    StringFormat=':: {0}'}"
            />
            <ItemsControl
                ItemsSource="{Binding Controls, Mode=OneWay, Source={StaticResource UserControlsViewModelDataSource}}"
                ItemTemplate="{StaticResource ItemsTemplate}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </StackPanel>
    </ScrollViewer>
</navigation:Page>
